﻿using Apewer.Web;
using System;
using System.Collections.Generic;
using System.Text;

namespace Apewer.AspNetBridge
{

    /// <summary></summary>
    public interface IHttpActionResult { }

    /// <summary></summary>
    public class HttpActionResult : IHttpActionResult
    {

        /// <summary></summary>
        public int Status { get; set; }

        /// <summary></summary>
        public string ContentType { get; set; }

        /// <summary></summary>
        public string Attachment { get; set; }

        /// <summary></summary>
        public byte[] Bytes { get; set; }

        /// <summary></summary>
        public StringPairs Cookies { get; set; }

        /// <summary></summary>
        public HttpActionResult()
        {
            Cookies = new StringPairs();
        }

        internal ApiModel ToModel()
        {
            var har = this;
            if (har == null) return new ApiStatusModel(204);
            var model = new ApiBytesModel();
            model.Status = har.Status;
            model.Bytes = har.Bytes;
            model.ContentType = har.ContentType;
            model.Attachment = har.Attachment;
            return model;
        }

    }

}
